#!/usr/bin/env python3

menu = {
  "家电" : {
      "电视" : [
          ["乐视","3000"],
          ["小米","2200"]
      ],
      "空调" : [
          ["奥克斯","5000"],
          ["格力","6000"]
      ],
      "洗衣机" : [
          ["LG","4000"],
          ["西门子","2000"]
      ],
  },
  "母婴" : {
      "奶粉" : [
          ["美素","400"],
          ["雀巢","300"]
      ],
      "玩具" : [
          ["积木","500"],
          ["小汽车","50"]
      ],
  },
  "图书" : {
      "少儿" : [
          ["绘本","30"],
          ["折纸书","50"]
      ],
      "科技" : [
          ["人人都是产品经理","100"],
          ["Python自动化教程","200"]
      ],
  },
}   # 通过字典实现三级菜单

layer = menu
p_layer = []

while True:
    for i in layer:
        print(i)
    choice = input(">:").strip()
    if len(choice) == 0:continue

    if choice in layer:
        p_layer.append(choice)
        layer = layer[choice]
    elif choice == "b":
        if len(p_layer) > 0:
            layer = p_layer.pop()

